package 每日一题;

public class 下一个更大元素1 {
    public int[] nextGreaterElement(int[] nums1, int[] nums2) {
        int[] res = new int[nums1.length];
        for (int i = 0; i < nums1.length; i++) {
            res[i] = find(nums2,nums1[i]);
        }
        return res;
    }
    //找到一个数组中比他大的值
    public int find(int[] nums,int num){
        int max;
        boolean lean = false;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i]==num)
                lean = true;
            if (lean && nums[i]>num)
                return nums[i];
        }
        return -1;
    }
}
